<?php

namespace App\Http\Requests;

class RoleUpdateRequest extends BaseRequest
{
    /**
     * Get the validation rules that apply to the request.
     * @return string[]
     */
    public function rules(): array
    {
        $id = $this->route('id');
        return [
            'name' => ['nullable','unique:admin_roles,name,' . $id],
            'description' => ['nullable'],
            'status' => ['nullable','in:0,1'],
            'sort' => ['nullable'],
        ];
    }

    public function messages(): array
    {
        return [
            'name.unique' => '角色名已存在',
            'status.in' => '状态不合法',
        ];
    }
}

